package main

import "fmt"

type Node struct {
	val int
	next *Node
}

func main() {
	a := Node{
		val:  1,
		next: nil,
	}
	b := Node{
		val:  2,
		next: &a,
	}
	c := Node{
		val:  3,
		next: &b,
	}
	d := Node{
		val:  4,
		next: &c,
	}

	head := d

	for {
		if head.next == nil {
			break
		}
		fmt.Printf("value = %d,", head.val)
		fmt.Printf("address = %p,", &head)
		fmt.Printf("next = %p\n", head.next)
		head = *head.next
	}
	fmt.Printf("value = %d,", head.val)
	fmt.Printf("address = %p", &head)
}
